package bit.client.view;

import bit.client.MainApp;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.ChoiceBox;
import javafx.scene.layout.AnchorPane;

public class RootLayoutController {
	
    @FXML
    private AnchorPane settings;
	
    @FXML
    private AnchorPane user;
    
    @FXML
    private AnchorPane classes;
    
    @FXML
    private AnchorPane score;
    
	ObservableList<String> schoolyearList = FXCollections
			.observableArrayList("鍏ㄩ儴", "2017-2018骞�", "2016-1017骞�", "2016-2017骞�", "2015-2016骞�");
	ObservableList<String> semesterList = FXCollections
			.observableArrayList("鍏ㄩ儴", "绗竴瀛︽湡", "绗簩瀛︽湡", "绗笁瀛︽湡");
	
	private MainApp mainApp;
	
	private int count_user = 0, count_settings = 0, count_score = 0, count_classes = 0;
	
	public void setMainApp(MainApp mainApp) {
    	this.mainApp = mainApp;
    }
	
    @FXML
    private ChoiceBox schoolyear;
    @FXML
    private ChoiceBox semester;
    
    public RootLayoutController() {
   
    }
    
    @FXML
   	private void initialize() {
   		schoolyear.setItems(schoolyearList);
   		semester.setItems(semesterList);
   	}
    
    @FXML 
    private void handleUser() {
    	count_settings = 0;
    	count_score = 0;
    	count_classes = 0;
    	count_user += 1;
    	settings.setVisible(false);
    	classes.setVisible(false);
    	score.setVisible(false);
    	if(count_user % 2 == 1) {
    		user.setVisible(true);
    	}
    	else {
    		user.setVisible(false);
    	}
    }
    
    @FXML 
    private void handleSettings() {
    	count_settings += 1;
    	count_score = 0;
    	count_classes = 0;
    	count_user = 0;
    	user.setVisible(false);
    	classes.setVisible(false);
    	score.setVisible(false);
    	if(count_settings % 2 == 1) {
    		settings.setVisible(true);
    	}
    	else {
    		settings.setVisible(false);
    	}
    }
    
    @FXML 
    private void handleScore() {
    	count_settings = 0;
    	count_score += 1;
    	count_classes = 0;
    	count_user = 0;
    	settings.setVisible(false);
    	classes.setVisible(false);
    	user.setVisible(false);
    	if(count_score % 2 == 1) {
    		score.setVisible(true);
    	}
    	else {
    		score.setVisible(false);
    	}
    }
    
    @FXML 
    private void handleClasses() {
    	count_settings = 0;
    	count_score = 0;
    	count_classes += 1;
    	count_user = 0;
    	settings.setVisible(false);
    	user.setVisible(false);
    	score.setVisible(false);
    	if(count_classes % 2 == 1) {
    		classes.setVisible(true);
    	}
    	else {
    		classes.setVisible(false);
    	}
    }
    
    @FXML
    private void handleExit() {
    	System.exit(0);
    }
    
}
